package com.base.commonlib.widget;

import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v7.app.AlertDialog;
import android.view.View;
import android.widget.TextView;

import com.base.commonlib.R;


/**
 * Created by arvin on 2018/10/29.
 */

public class ParkCheckDialog extends AlertDialog {
    private Context mContext;
    private TextView mTv_neg;
    private TextView mTv_pos;
    private TextView mTv_number;
    private TextView mTv_type;
    private ParkCheckDialog.OnNegClick mOnNegClick;
    private ParkCheckDialog.OnPosClick mOnPosClick;

    private String mNumber;
    private String mType;
    private String mAddress;


    public void setOnNegClick(ParkCheckDialog.OnNegClick onNegClick)
    {
        mOnNegClick=onNegClick;
    }

    public void setOnPosClick(ParkCheckDialog.OnPosClick onPosClick)
    {
        mOnPosClick=onPosClick;
    }

    public ParkCheckDialog(@NonNull Context context) {
        super(context, R.style.dialog);
        mContext=context;
    }


    public void setNumber(String number) {
        mNumber = number;
    }

    public void setType(String type) {
        mType = type;
    }

    public void setAddress(String address) {
        mAddress = address;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.parkcheck_dialog_layout);
        mTv_neg = findViewById(R.id.tv_neg);
        mTv_pos = findViewById(R.id.tv_pos);
        mTv_number = findViewById(R.id.tv_number);
        mTv_type = findViewById(R.id.tv_type);
        mTv_number.setText(mNumber);
        mTv_type.setText(mType);


        mTv_neg.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
                if(mOnNegClick!=null)
                {
                    mOnNegClick.onClick();
                }
            }
        });
        mTv_pos.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
                if(mOnPosClick!=null)
                {
                    mOnPosClick.onClick();
                }
            }
        });
    }

    public interface OnNegClick
    {
        void onClick();
    }

    public interface OnPosClick
    {
        void onClick();
    }
}
